package com.zhiyou.brank.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.zhiyou.brank.service.FlyScoreService;
import com.zhiyou.model.FyScore;
import com.zhiyou.utils.JsonResult;

@RestController
@RequestMapping("score/")
public class FlyScoreController {	
	@Autowired
	FlyScoreService flyScoreService;
	@GetMapping("selectScoreOne/{student_id}/{exam_id}")
	public JsonResult selectScoreOne(@PathVariable("student_id")Integer student_id,@PathVariable("exam_id")Integer exam_id,HttpServletResponse req,HttpServletRequest rep){	
		return new JsonResult(flyScoreService.selectScoreOne(student_id, exam_id), "查询成功");	 
	}
	@PostMapping("addScore")
	public void addScore(FyScore fyScore,HttpServletResponse req,HttpServletRequest rep){	
		flyScoreService.addScore(fyScore);
	}
	@PostMapping("updateScore")
	public void updateScore(FyScore fyScore,HttpServletResponse req,HttpServletRequest rep){	
		flyScoreService.updateScore(fyScore);
	}
	@GetMapping("selectScoreAll")
	public JsonResult selectScoreAll(HttpServletResponse req,HttpServletRequest rep){	
		return new JsonResult(flyScoreService.selectScoreAll(),"查询成功");
	}
	@GetMapping("selectScoreByName/{student_name}/{exam_id}")
	public JsonResult selectScoreByName(@PathVariable("student_name")String student_name,@PathVariable("exam_id")Integer exam_id,HttpServletResponse req,HttpServletRequest rep){	
		return new JsonResult(flyScoreService.selectScoreByName(student_name, exam_id),"查询成功");
	}
	@GetMapping("deleteScore/{score_id}")
	public void deleteScore(@PathVariable("score_id")Integer score_id,HttpServletResponse req,HttpServletRequest rep){	
		flyScoreService.deleteScore(score_id);
	}
}
